package com.yizhubao.app.adapters;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xw.repo.XEditText;
import com.yizhubao.app.R;
import com.yizhubao.app.beans.RecordBean;
import com.yizhubao.app.beans.SelectImageBean;
import com.yizhubao.app.customviews.ZpPhoneEditText;

import h.framework.pacy.utils.ImageUtil;
import h.framework.pacy.utils.LogUtil;
import h.framework.pacy.utils.StringUtil;

/**
 * @author Pacy.
 * Date: 2021/6/4/004
 * Time: 21:18
 * Mail pengwwe457621023@qq.com
 * Info 发布委托人adapter
 */
public class ReleaseUserAdapter extends BaseQuickAdapter<RecordBean.AssignorListDTO, BaseViewHolder> {
    XEditText phone_et;
    EditText name_et;

    public ReleaseUserAdapter() {
        super(R.layout.release_user_item);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, RecordBean.AssignorListDTO item) {
        helper.addOnClickListener(R.id.userDelete_tv);
        phone_et=helper.getView(R.id.phone_et);
        phone_et.setSeparator(" ");
        phone_et.setPattern(new int[]{3,4,4});
        phone_et.setDisableClear(true);
        if(StringUtil.isNotEmpty(item.getPhone())){
            phone_et.setText(item.getPhone());
        }else{
            phone_et.setText("");
        }
        phone_et.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                item.setPhone(s.toString());
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

        name_et=helper.getView(R.id.name_et);
        if(StringUtil.isNotEmpty(item.getName())){
            name_et.setText(item.getName());
        }else{
            name_et.setText("");
        }
        name_et.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                item.setName(s.toString());
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });
    }
}
